package com.per.mybootall.test;

import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: yyy
 * Date: 2021/12/21
 * Time: 14:21
 * Description:【stream的->后面不跟大括号默认返回当前语句，加了大括号需要return】
 */
public class test04 {
    public static void main(String[] args) {
        List<Integer> paramList=new ArrayList(){{add(1);add(2);add(3);add(4);add(5);add(1);add(2);add(3);add(4);add(5);add(1);}};

        List<Map> paramMapList=new ArrayList(){{add(new HashMap(){{put("age",1);}});add(new HashMap(){{put("age",2);}});add(new HashMap(){{put("age",5);}});
        add(new HashMap(){{put("age",3);}});add(new HashMap(){{put("age",4);}});add(new HashMap(){{put("age",9);}});add(new HashMap(){{put("age",7);}});
        add(new HashMap(){{put("age",6);}});add(new HashMap(){{put("age",8);}});add(new HashMap(){{put("age",11);}});}};

//        List newlIST=paramList.stream().map(param ->{
//            param=param*2;
//            return param;
//        }).collect(Collectors.toList());
//
//        newlIST.forEach(System.out::println);



       // paramList.stream().map(param->param*3).collect(Collectors.toList()).forEach(System.out::println);

       // paramList.stream().filter(param->param==2).collect(Collectors.toList()).forEach(System.out::println);

        //paramList.stream().sorted(Comparator.comparing(param->param)).forEach(System.out::println);

        //paramMapList.stream().sorted(Comparator.comparing(param->Integer.valueOf(param.get("age").toString()))).forEach(System.out::println);

        System.out.println(paramMapList.stream().mapToInt(each-> Integer.parseInt(each.get("age").toString())).max().getAsInt());;
//        System.out.println(paramMapList.stream().max(Comparator.comparing(param -> {
//            return Integer.valueOf(param.get("age").toString());
//        })).get().get("age"));
    }
}
